package com.bzxgc.sgwer.service.impl.menu;

import com.bzxgc.sgwer.dao.menu.MenuMapper;
import com.bzxgc.sgwer.entity.menu.Menu;
import com.bzxgc.sgwer.entity.role.Role;
import com.bzxgc.sgwer.service.menu.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service("menuService")
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public void addMenu(Menu menu) {
        menu.setAddTime(new Date());
        menu.setStatus(1);
        menuMapper.addMenu(menu);
    }

    @Override
    public void updateMenu(Menu menu) {
        menu.setUpdateTime(new Date());
        menuMapper.updateMenu(menu);
    }

    @Override
    public void updateMenuStatus(Long[] ids, Integer status) {
        menuMapper.updateMenuStatus(ids, status);
    }

    @Override
    public List<Menu> getAllMenu() {
        return menuMapper.getAllMenu();
    }

    @Override
    public List<Menu> getAllOneMenu() {
        return menuMapper.getAllOneMenu();
    }

    @Override
    public Menu getMenuById(Long id) {
        return menuMapper.getMenuById(id);
    }

    @Override
    public List<Menu> getAllOneMenuNoChildren() {
        return menuMapper.getAllOneMenuNoChildren();
    }

    @Override
    public List<Menu> getOneMenuByRoleIds(List<Role> roleList) {
        return menuMapper.getOneMenuByRoleIds(roleList);
    }
}

